#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QTimer>
#include <QTcpServer>
#include <QTcpSocket>
#include <QVector>
#include <QTreeView>
#include <QFileSystemModel>
#include <QDomDocument>
#include <QDomElement>
#include <QDomNode>
#include <QTreeWidget>
#include <QByteArray>

#include "unionhmidll_global.h"
#include "PluginInterface/teccontrollerhmi_interface.h"
#include "PluginInterface/robcontrollerhmi_interface.h"

#include "WorkThreadManage/servercommange.h"

#define UnionAllSys 0
#define UnionAllTechHmi 1
#define UnionAllTc3Robot1 2

namespace Ui { class MainWindow; }

typedef struct MessageNumber{
   int NormalMessageNumber;
   int WarningMessageNumber;
   int ErrorMessageNumber;
}MessageNumber;

class HmiThread : public QMainWindow{
    Q_OBJECT

public:
    explicit HmiThread(QWidget *parent = 0);
    ~HmiThread();

private:
    bool    RunLed;
    short   ControllerHmiPage;

    Ui::MainWindow *ui;     //系统界面主框架

    MessageNumber    mMessageNumber;
    QVector<QString> NormalMessage;
    QVector<QString> WarningMessage;
    QVector<QString> ErrorMessage;

    HmiServer* pHmiServerHandle = nullptr;

public:
    TecControllerHMI*  pTecControllerHMI;
    RobControllerHMI*  pRobControllerHMI;
public:
    short MainWindowInit();
    short MainWindowShow();
    short MainWindowHide();

    short WriteMessageBox(MessageType Type,const QString Data);
    short WriteProgressBar(const int value);

    void  GetHmiServerHandle(HmiServer* p);
private:
    short HmiMessageBoxShow();
    short HmiPluginInstanceHMILoading();
    short SignalSlotConnect();

public slots:
    void FastTimerUpdate();
    void SlowTimerUpdate();
public slots:
    void onbtnclicked_Switch_Clicked();

    void onbtnclicked_vPower();
    void onbtnclicked_ESTOP();
    void onbtnclicked_Home();

    void onbtnclicked_Setting();
    void onbtnclicked_Edit();
    void onbtnclicked_Pause();
    void onbtnclicked_Run();
    void onbtnclicked_Stop();

    void onbtnclicked_fn1();
    void onbtnclicked_fn2();
    void onbtnclicked_fn3();
    void onbtnclicked_fn4();

    void onbtnpressed_fn1();
    void onbtnpressed_fn2();
    void onbtnpressed_fn3();
    void onbtnpressed_fn4();

    void onbtnreleased_fn1();
    void onbtnreleased_fn2();
    void onbtnreleased_fn3();
    void onbtnreleased_fn4();

    void onbtnclicked_MainScriptStatus();
    void onbtnclicked_SubScriptStatus();
    void onbtnclicked_VisHmi();
    void onbtnclicked_Coordinate();

    void onbtnclicked_MessageDone();
    void onbtnclicked_MessageAllDone();
    void onbtnclicked_MessageDetail();

    void onbtnpressed_XP();
    void onbtnpressed_YP();
    void onbtnpressed_ZP();
    void onbtnpressed_AP();
    void onbtnpressed_BP();
    void onbtnpressed_CP();
    void onbtnpressed_XN();
    void onbtnpressed_YN();
    void onbtnpressed_ZN();
    void onbtnpressed_AN();
    void onbtnpressed_BN();
    void onbtnpressed_CN();

    void onbtnreleased_XP();
    void onbtnreleased_YP();
    void onbtnreleased_ZP();
    void onbtnreleased_AP();
    void onbtnreleased_BP();
    void onbtnreleased_CP();

    void onbtnreleased_XN();
    void onbtnreleased_YN();
    void onbtnreleased_ZN();
    void onbtnreleased_AN();
    void onbtnreleased_BN();
    void onbtnreleased_CN();

    void onbtnpressed_E1P();
    void onbtnpressed_E1N();
    void onbtnpressed_E2P();
    void onbtnpressed_E2N();

    void onbtnreleased_E1P();
    void onbtnreleased_E2P();
    void onbtnreleased_E1N();
    void onbtnreleased_E2N();

    void onbtnclicked_MannualOverrideP();
    void onbtnclicked_MannualOverrideN();
    void onbtnclicked_ProgramOverrideP();
    void onbtnclicked_ProgramOverrideN();
};

#endif // MAINWINDOW_H
